#pragma once
#include "techview.hpp"

namespace zqdb {

	//////////////////////////////////////////////////////////////////////////
	///画线部分

	class Drawline;

	//0:None; 1:修改端点; 2:平移
	enum
	{
		MODIFY_NONE = 0,
		MODIFY_POINT,
		MODIFY_SHIFT,
	};

	//0:undefine; 1:standby; 2:OnModify; 3:DrawShawdow
	enum
	{
		DRAW_STATUS_UNDEFINE = 0,
		DRAW_STATUS_DEFINE,
		DRAW_STATUS_MODIFY,
		DRAW_STATUS_SHAWDOW,
	};

	class Point
		: public wxPoint
		, public tagCalcPoint
	{
	public:
		Point() : wxPoint(0, 0), tagCalcPoint{0., 0, 0}
		{
		}
		Point(const wxPoint& pt) : wxPoint(pt), tagCalcPoint{ 0., 0, 0 }
		{
		}
	};

	class Drawline
		: public Indicator
	{
	public:
		typedef Drawline This;
		typedef Indicator Base;
	protected:
		//CMemDC	m_dc;
		size_t status_ = 0;
		inline void SetStatus(int status) { status_ = status; }
		inline size_t GetStatus() { return status_; }
		Point	m_pt; //平移点
		std::vector<Point> m_pts;	//操作点，对应调整点
		std::vector<Point> m_dpts; //绘制点,显示点，屏幕先显示的点，和显示的数据等，这些数据是计算出来，只显示用，不作其他用途
		unsigned int m_nDPointNumber;
		unsigned int m_nActivePos : 8;
		unsigned int m_bCalc : 1;
		unsigned int m_nModifyType : 7;
		unsigned int m_nID : 16;
		void Init();
	public:
		Drawline(Windicator* parent, const char* xml = nullptr, size_t xmlflag = XUtil::XML_FLAG_JSON_STRING);
		Drawline(Indicator* ind, HZQDB h);
		virtual ~Drawline();

	public:
		inline bool IsInDrawline() { return GetStatus() == DRAW_STATUS_UNDEFINE; }

		void OnSkinInfoChanged();
		void OnCalcDataChanged();
		void OnCalcDataUpdated();
		void OnDispInfoChanged(size_t Changed);
		void OnDispInfoExChanged();

		void OnMove();
		void OnSize();

		void OnMouse(wxMouseEvent &event);
		void OnCaptureLost(wxMouseCaptureLostEvent& event);
		void OnChar(wxKeyEvent &event);

		void Paint(wxDC& dc);

		bool GetDispPointInfoEx(std::shared_ptr<PointInfoEx> infoPtr);

	protected:
		void CalcPointRect(Rect& rc, const Point& pt);

		void Draw(wxDC& dc, Rect& rc);
		void DrawPoint(wxDC& dc, const Point &pt);

		bool get_lpt(Point &pt, const Point& pt1, const Point& pt2);
		bool get_rpt(Point &pt, int radius);

		void CalcDLine(const Point& pt); //位移到pt
		void CalcDDLine(const Point& pt1, const Point& pt2); //计算两点位置
		void CalcPLine(const Point& pt); //计算平行线
		void CalcPerLine(const Point& pt1, const Point& pt2);
		void CalcRadialLine(const Point& pt1, const Point& pt2);
		void CalcBarLine(const Point& pt1, const Point& pt2, const Point& pt3);
		void CalcGoldLine(const Point& pt1, const Point& pt2);
		//void CalcUgunsLine(const Point& pt1);
		//void CalcDgunsLine(const Point& pt1);
		void CalcGunsLine(const Point& pt1, const Point& pt2);
		void CalcBlackHole(const Point& pt1, const Point& pt2);
		void CalcEllipseArc(const Point& pt1, const Point& pt2);
		void CalcMultiArc(const Point& pt1, const Point& pt2);
		void CalcGoldArc(const Point& pt1, const Point& pt2);
		void CalcCircle(const Point& pt1, const Point& pt2);
		void CalcMultiEllipse(const Point& pt1, const Point& pt2);
		void CalcCycleLine(const Point& pt1, const Point& pt2);
		void CalcFabCycleLine(const Point& pt1);
		void CalcSuzuLine(const Point& pt1, const Point& pt2);
		void CalcSinLine(const Point& pt1, const Point& pt2);
		void CalcRectangle(const Point& pt1, const Point& pt2);
		void CalcText(const Point& pt1);
		void CalcUpArrow(const Point& pt1);
		void CalcDownArrow(const Point& pt1);
		void CalcStockBox(const Point& pt1, const Point& pt2);
		void CalcRegressLine(const Point& pt1, const Point& pt2);
		void CalcRegressZone(const Point& pt1, const Point& pt2);
		void CalcRegressChannel(const Point& pt1, const Point& pt2);

		void Line(wxDC& dc, const Point& pt1, const Point& pt2);
		void DashLine(wxDC& dc, const Point& pt1, const Point& pt2);
		void Circle(wxDC& dc, const Point& rpt, int radius);
		void DashCircle(wxDC& dc, const Point& rpt, int radius);
		void HCycle(wxDC& dc, const Point& pt1, const Point& pt2, const Point& rpt, int radius);
		void DashHCycle(wxDC& dc, const Point& pt1, const Point& pt2, const Point& rpt, int radius);
		void Arc(wxDC& dc, const Point& pt1, const Point& pt2, const Point& rpt1, const Point& rpt2);
		void DashArc(wxDC& dc, const Point& pt1, const Point& pt2, const Point& rpt1, const Point& rpt2);
		void Ellipse(wxDC& dc, const Point& rpt1, const Point& rpt2);
		void DashEllipse(wxDC& dc, const Point& rpt1, const Point& rpt2);
	};

}
